package com.learn.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.learn.dto.Role;
import com.learn.mapper.RoleMapper;
import com.learn.service.impl.RoleServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
@RequiredArgsConstructor
public class RoleService implements RoleServiceImpl {

    private final RoleMapper roleMapper;

    @Override
    public List<Role> findAll() {
        return roleMapper.findAll();
    }
//    增加
    @Override
    public Integer insert(Role role) {
        return roleMapper.insert(role);
    }// 删除
    @Override
    public int delete(Integer id) {
        return roleMapper.delete(id);
    }
    //批量s删除
    @Override
    public int deletes(List<Integer> ids) {
        return  roleMapper.deletes(ids);
    }
//修改
    @Override
    public Integer update(Role role) {
        return roleMapper.update(role);
    }
    @Override
    public PageInfo<Role> getPage(int pageNum, int pageSize, String name, LocalDateTime beginTime, LocalDateTime endTime) {

        PageHelper.startPage(pageNum,pageSize);
        System.out.println("分页查询");
        // 执行查询
        List <Role> list = roleMapper.getPage(name,beginTime,endTime);
        return new PageInfo<>(list);
    }


}
